
package com.gzbsoft.sc.modules.sys.entity;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import io.ebean.annotation.DbComment;
import io.ebean.annotation.DocStore;
import lombok.*;

import javax.persistence.*;
import java.util.List;
/**
 * 菜单管理
 *
 * @author Mark sunlightcs@gmail.com
 */
@DocStore
@EqualsAndHashCode(callSuper = true)
@Entity
@Data
@Table(name = "sys_menu")
@Builder
@NoArgsConstructor
@AllArgsConstructor
@DbComment("系统菜单")
public class SysMenu extends BaseEntity {
    @ManyToOne(cascade = CascadeType.REFRESH)
    @JoinColumn(name = "parent_id")
    @JsonBackReference
    private SysMenu parent;
    @DbComment("父级id的集合")
    private String parentIds;
    private String name;
    private String url;
    @DbComment("权限字符, 逗号数组")
    private String perms;
    @DbComment("类型,0：目录,1：菜单,2：按钮")
    private Integer type;
    private String icon;
    private Integer orderNum;
    @Transient
    @JsonManagedReference
    private List<SysMenu> children;
    @Override
    public String toString() {
        return "SysMenu{" +
                "name='" + name + '\'' +
                ", url='" + url + '\'' +
                ", perms='" + perms + '\'' +
                ", type=" + type +
                ", icon='" + icon + '\'' +
                ", orderNum=" + orderNum +
                ", id=" + id +
                '}';
    }
}
